//
//  TopicTableViewCell.m
//  HappinessTrip
//
//  Created by dllo on 15/10/7.
//  Copyright © 2015年 蓝鸥科技. All rights reserved.
//

#import "TopicTableViewCell.h"
#import "UIImageView+WebCache.h"
#import "Fit.h"

@implementation TopicTableViewCell
-(void)dealloc
{
    [_pictureImageView release];
    [_blackImageView release];
    [_titleLabel release];
    [_smallLabel release];
    [super dealloc];
}
-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self createViews];
    }
    return self;
}
-(void)createViews
{
    _pictureImageView = [[UIImageView alloc]init];
    [self.contentView addSubview:_pictureImageView];
    [_pictureImageView release];
    _blackImageView = [[UIImageView alloc]init];
    [_pictureImageView addSubview:_blackImageView];
    [_blackImageView release];
    _titleLabel = [[UILabel alloc]init];
    [_pictureImageView addSubview:_titleLabel];
    [_titleLabel release];
    _smallLabel = [[UILabel alloc]init];
    [_pictureImageView addSubview:_smallLabel];
    [_smallLabel release];
    
}
-(void)layoutSubviews
{
    [super layoutSubviews];
    _pictureImageView.frame = CGRectMake(10 * W, 5 * H, self.contentView.frame.size.width - 20 * W, self.contentView.frame.size.height - 10 * H);
    _blackImageView.frame = CGRectMake(0, 0, _pictureImageView.frame.size.width, _pictureImageView.frame.size.height);
    _titleLabel.frame = CGRectMake(20 * W, 20 * H, _pictureImageView.frame.size.width - 40 * W, 60 * H);
    _smallLabel.frame = CGRectMake(_titleLabel.frame.origin.x, _titleLabel.frame.origin.y + _titleLabel.frame.size.height + 20 * H, _titleLabel.frame.size.width, 50 * H);
}
-(void)setAllData:(AllData *)allData
{
    if (_allData != allData) {
        [_allData release];
        _allData = [allData retain];
    }
    [_pictureImageView sd_setImageWithURL:[NSURL URLWithString: _allData.cover] placeholderImage:[UIImage imageNamed:@"dengdai"]];
    _pictureImageView.layer.cornerRadius = 5;
    _pictureImageView.layer.masksToBounds = YES;
    _blackImageView.backgroundColor = [UIColor blackColor];
    _blackImageView.alpha = .2;
    _blackImageView.layer.cornerRadius = 5;
    _blackImageView.layer.masksToBounds = YES;
    if (_allData.sub_title) {
        _titleLabel.text = _allData.sub_title;
    }
    else {
        _titleLabel.text = _allData.cover_title;
    }
    _titleLabel.textColor = [UIColor whiteColor];
    _titleLabel.font = [UIFont systemFontOfSize:25];
    _titleLabel.textAlignment = 1;
    if (_allData.cover_sub_title) {
        _smallLabel.text = [NSString stringWithFormat:@"「 %@ 」", _allData.cover_sub_title];
    }
    else {
        _smallLabel.text = [NSString stringWithFormat:@"「 %@ 」", _allData.title];
    }
    _smallLabel.textColor = [UIColor whiteColor];
    _smallLabel.font = [UIFont systemFontOfSize:20];
    _smallLabel.textAlignment = 1;
    _smallLabel.numberOfLines = 0;
}








- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
